<?php

namespace app\admin\model;
use think\Db;
use think\Model;

class ComplainMessage extends Model {

    public function __construct() {
        parent::__construct();
    }

    //投诉配置列表
    public function getListInfo($page, $limit, $data) {
        $where = [];
        if(!empty($data['complain_message'])){
            $where['complain_message'] = ['like','%'.rtrim($data['complain_message']).'%'];
        }
        //分页
        $start = ($page - 1) * $limit;
        $count = Db::name('complain_message')->where($where)->count();
        $list  = Db::name('complain_message')->where($where)->limit($start, $limit)->order('complain_id desc')->select();
        foreach ($list as $key=>$value){
            $list[$key]['orderTypeName'] = order_type($value['order_type']);
            if(!empty($value['user_or_driver'])){
                $list[$key]['appName'] = '乘客';
            }else{
                $list[$key]['appName'] = '司机';
            }
            $list[$key]['add_time']     = !empty($value['add_time'])?date("Y-m-d H:i:s",$value['add_time']):'';
            $list[$key]['update_time']  = !empty($value['update_time'])?date("Y-m-d H:i:s",$value['update_time']):'';
        }
        return array(
            'code' => 0,
            'msg' => '',
            'count' => $count,
            'data' => $list
        );
    }
}
